package org.jpropelleralt.node;

import org.jpropelleralt.path.PathStep;
import org.jpropelleralt.ref.Ref;

/**
 * A {@link Node} having a name {@link Ref}
 * with a {@link String} value.
 * The name should be a brief, one line identifier
 * for the {@link Node} itself.  
 */
public interface Named extends Node {
	
	/**
	 * Get the name of this {@link Node}
	 * Note that the {@link Ref} returned from this
	 * method must have the ref-name "name" in
	 * this {@link Node}.
	 * @return	{@link Node}'s name, as a {@link Ref}
	 */
	public Ref<String> name();
	
	/**
	 * The ref-name used within {@link Named} nodes to
	 * refer to their name property.
	 */
	public final static String NAME = "name";
	
	/**
	 * {@link PathStep} from a {@link Named} to its
	 * {@link Named#name()} {@link Ref}.
	 */
	PathStep<Named, String> toName = new PathStep<Named, String>() {
		public Ref<String> transform(Named s) {
			return s.name();
		};
	};
}
